<?php
namespace  Teachers\Controller;
use Think\Controller;
/*
	高校详情控制器
*/
class DetailsController extends CommonController
{
	/**
	 * 查询高校详情
	 * */
	public function index()
	{	
		$school_id=$this->showschoolID();
		if($school_id)
		{	
			$details=M('SchoolInfo');
			$map['school_id']=$school_id;
			$details_data=$details->where($map)->find();
//			dump($details_data);
			$this->assign('details_data',$details_data);
			$this->display();
		}
	}
	
	/**
	 * 更新高校详情
	 * 
	 * */
	public function updateDetails(){
		$details=M('SchoolInfo');
		$school_id=$this->showschoolID();
		$content=I('post.content','');
		$type=I('post.type');
		$info_id=I('post.info_id');
		if($info_id){		//存在则更新，不存在则新增
			$map=array(
				'school_id'	=> $school_id,
				'info_id'	=> $info_id,
			);
			$data=array(
				$type	=> $content,
			);
			$flag=$details->where($map)->save($data);
			if(!$flag){
				$this->error('保存出错!');
			}
//			$this->ajaxReturn($flag);
		}else{
			$data=array(
				$type		=> $content,
				'school_id'	=> $school_id,
			);
			$details_id=$details->add($data);
			if(!$details_id){
				$this->error('保存出错!');
			}
//			$this->ajaxReturn($details_id);
		}
	}
	
	


}